<template>
    <div>
      <el-dialog
        title="添加采购"
        :visible.sync="dialogVoidReasonVisible"
        width="30%">

        <el-form :model="form" ref="form" label-width="100px" class="demo-ruleForm">

        <el-form-item
          label="作废原因"
          prop="remark"
          :rules="[{ required: true, message: '作废原因不能为空'},]"
        >
          <el-input  v-model="form.remark" autocomplete="off"></el-input>
        </el-form-item>


          <el-form-item>
            <el-button type="primary" @click="_addToCart('form')">添加</el-button>
            <el-button @click="dialogAddCartVisible = false">关闭</el-button>
          </el-form-item>

        </el-form>





      </el-dialog>
    </div>
</template>

<script>
    export default {
        name: "GoodsProductAddCart",

      data(){
          return{
            dialogVoidReasonVisible:false,
            form:{
              remark:'',
              purchaseId:''
            }




          }
      },
      methods:{
        _open(id){
          this.form.remark='';
          this.form.purchaseId=id;
          this.dialogVoidReasonVisible=true;
        },

        _addToCart(formName) {
          this.$refs[formName].validate((valid) => {
            if (valid) {

              this.$http.post("/t_purchase/to_void?ids="+this.form.purchaseId+'&remark='+this.form.remark).then(result=>{
                console.log("result:"+result)

                this.dialogVoidReasonVisible=false;
                this.$emit('on-result-change')

              }).catch(err=>{
                console.log(err);
              })


            } else {
              console.log('error submit!!');
              return false;
            }
          });
        },



      },
    }
</script>

<style scoped>

</style>
